<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./template.js"></script>
</head>

<body>
    <div id="box"></div>
    <script type="text" id="tpl">
        <h1>{{time |dataformat}}</h1>
    </script>
    <script>
        let data = {
            time: new Date()

        }
        template.defaults.imports.dataformat = function (value) {
            return 最终显示的值
        }
        let str = template('tpl', data)
        $('#box').html(str)
    </script>
</body>

</html>